<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>新经资讯后台管理</title>
	<link rel="stylesheet" type="text/css" href="../../static/admin/css/reset.css">
	<link rel="stylesheet" type="text/css" href="../../static/admin/css/main.css">
	<link rel="stylesheet" href="../../static/admin/css/jquery.pagination.css">
	<script type="text/javascript" src="../../static/admin/js/jquery-1.12.4.min.js"></script>
	<script type="text/javascript" src="../../static/admin/js/jquery.pagination.min.js"></script>
</head>
<body>
	<div class="breadcrub" >
			当前位置：新闻管理>新闻审核
			<form class="news_filter_form">
				<input type="text" placeholder="请输入关键字" class="input_txt" name="keyword" value="">
				<input type="button" value="搜 索" class="input_sub">
			</form>
		</div>
		<div class="pannel">
			<table class="common_table">
					<tr>
							<th width="3%">id</th>
							<th width="7%">标题</th>
							<th width="15%">发布时间</th>
							<th width="15%">状态</th>
							<th width="10%">失败原因</th>
							<th width="8%">管理操作</th>
						</tr>
			</table>
			<table class="common_table" id='showmes'>
				
				
				
			</table>
		</div>
		<div id='pagination'>

		</div>
</body>
<script>
getNewslist(1,'')
//获取新闻列表
function getNewslist(p,keyword){
	$.ajax({
		url:'/admin/getNewslist',
		type:'get',
		data:{'p':p,'keyword':keyword},
		dataType:'json',
		success:function(res){
			if(res.code = 200){
				var news = res.news
				var len = news.length
				var html=""
				for(var i=0;i<len;i++){
					if(news[i]['status'] == 0){
						html+='<tr style="width:1000px;"><td>'+news[i]['id']+' </td><td class="tleft">'+news[i]['title']+'</td>'+
'<td class="tleft">'+news[i]['create_time']+'</td><td class="tleft">审核中</td><td>'+
	'<a href="/admin/detail?id='+news[i]['id']+'" class="review">审核</a></td><td></td></tr>'
					}else if(news[i]['status']==1){
						html+='<tr><td>'+news[i]['id']+' </td><td class="tleft">'+news[i]['title']+'</td>'+
'<td class="tleft">'+news[i]['create_time']+'</td><td class="tleft">审核通过</td><td>'+
	'</td><td></td></tr>'
					}else{
						html+='<tr><td>'+news[i]['id']+' </td><td class="tleft">'+news[i]['title']+'</td>'+
'<td class="tleft">'+news[i]['create_time']+'</td><td class="tleft">审核失败</td><td>'+
	'</td><td>'+news[i]['reason']+'</td></tr>'
					}
					
				}
				$("#showmes").html(html)
				page(res.total_page,res.current_page)
			}else{
				alert(res.message)
			}
		}
	})
}

//分页方法
function page(tpage,cpage){
	$("#pagination").pagination({
		totalPage:tpage,
		currentPage:cpage,
		callback:function(current){
			var keyword = $(".input_txt").val()
			getNewslist(current,keyword)
		}
	})

}
$(function(){
	$(".input_sub").click(function(){
		var keyword = $(".input_txt").val()
		if (keyword){
			getNewslist(1,keyword)
		}else{
			alert("请输入您要搜索的标题")
			return;
		}
	})
})
</script>
</html>